#delimit ;
set more off;

/*NOTE: For a Mac, file path names use a forward slash (/) but for 
PC's they require a backward slash (\). Make these changes below 
if necessary depending on your computer type. Also, install the estout 
command if you haven't already done so:
ssc install estout
*/

*Dropbox paths by user;
if c(username)=="shayaksarkar" {;
	local path "/Users/shayaksarkar/Desktop/ReStat_Data_Publication";
};

*Dropbox paths by user;
local path "C:/Users/anagol/Dropbox/ReStat_Data_Publication";


/*TABLE 4*/;

cd `path';

use "`path'/dta/STATA12versions/final_competition.dta", clear;
	
	local se cluster(date_auditor);

	local rhs1 biasterm needterm comp;
	
	local rhs2 bt_comp nt_comp bnterm bnterm_comp;
	
	local controls govt_und agent_home auditor_home auditor_office other_venue;

	reg anyterm `rhs1', `se';
	estadd ysumm;
	eststo;

	areg anyterm `rhs1' `controls', absorb(ms_id) `se';
	estadd ysumm;
	eststo;

	reg anyterm `rhs1' `rhs2', `se';
	estadd ysumm;
	eststo;

	** Compare those who believe whole, need term, low comp;
		** to those who believe whole, need term, high comp;
		
	test comp +nt_comp=0;
	
	areg anyterm `rhs1' `rhs2' `controls', absorb(ms_id) `se';
	estadd ysumm;
	eststo;

	test comp +nt_comp=0;
	
	reg onlyterm `rhs1', `se';
	estadd ysumm;
	eststo;

	areg onlyterm `rhs1' `controls', absorb(ms_id) `se';
	estadd ysumm;
	eststo;

	reg onlyterm `rhs1' `rhs2', `se';
	estadd ysumm;
	eststo;

	areg onlyterm `rhs1' `rhs2' `controls', absorb(ms_id) `se';
	estadd ysumm;
	eststo;
	
* Output to Excel file;
esttab est1 est2 est3 est4 est5 est6 est7 est8 using "`path'/out/table4.csv", replace 
cells("b(fmt(5)) _star" se(fmt(5)))  starlevels(* .1 ** .05 *** .01) 
stats (ymean N, fmt( 5 %12.0fc) label("Dep. Var. Mean" N )) plain;
eststo clear;
	


	
